﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApC3DDocumentationSettings
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

internal class CApC3DDocumentationSettings
{
  private bool m_storeAllSnapshots;
  private bool m_compress3DDocuments;
  private bool m_recordAnimation;
  private bool m_includePMIs = true;
  private CApC3DDocumentationSettings.CApC3DIncludedObjectsMode m_includedObjectsMode = CApC3DDocumentationSettings.CApC3DIncludedObjectsMode.OnlyObjectsIncludedInSnapshotsAndSimulation;
  private TxExportGraphicsAnimationFileFormatEx m_pdfMode = (TxExportGraphicsAnimationFileFormatEx) 1;
  private int m_levelOfDetails = 1;

  public CApC3DDocumentationSettings()
  {
    int? nullable1 = this.LoadRegistryValue(CApDataFileDefinitions.StoreAllSnapshots);
    if (nullable1.HasValue)
      this.m_storeAllSnapshots = nullable1.Value == 1;
    int? nullable2 = this.LoadRegistryValue(CApDataFileDefinitions.CompressDataAttribute);
    if (nullable2.HasValue)
      this.m_compress3DDocuments = nullable2.Value == 1;
    int? nullable3 = this.LoadRegistryValue(CApDataFileDefinitions.AnimationAttribute);
    if (nullable3.HasValue)
      this.m_recordAnimation = nullable3.Value == 1;
    int? nullable4 = this.LoadRegistryValue(CApDataFileDefinitions.IncludePMIsAttribute);
    if (nullable4.HasValue)
      this.m_includePMIs = nullable4.Value == 1;
    int? nullable5 = this.LoadRegistryValue(CApDataFileDefinitions.LevelOfDetailsAttribute);
    if (nullable5.HasValue)
      this.m_levelOfDetails = nullable5.Value;
    int? nullable6 = this.LoadRegistryValue(CApDataFileDefinitions.IncludedObjectsMode);
    if (!nullable6.HasValue)
      return;
    this.m_includedObjectsMode = (CApC3DDocumentationSettings.CApC3DIncludedObjectsMode) nullable6.Value;
  }

  public bool StoreAllSnapshots
  {
    get => this.m_storeAllSnapshots;
    set
    {
      this.m_storeAllSnapshots = value;
      this.SaveRegistryValue(CApDataFileDefinitions.StoreAllSnapshots, this.m_storeAllSnapshots ? 1 : 0);
    }
  }

  public bool RecordAnimation
  {
    get => this.m_recordAnimation;
    set
    {
      this.m_recordAnimation = value;
      this.SaveRegistryValue(CApDataFileDefinitions.AnimationAttribute, this.m_recordAnimation ? 1 : 0);
    }
  }

  public bool Compress3DDocuments
  {
    get => this.m_compress3DDocuments;
    set
    {
      this.m_compress3DDocuments = value;
      this.SaveRegistryValue(CApDataFileDefinitions.CompressDataAttribute, this.m_compress3DDocuments ? 1 : 0);
    }
  }

  public bool IncludePMIs
  {
    get => this.m_includePMIs;
    set
    {
      this.m_includePMIs = value;
      this.SaveRegistryValue(CApDataFileDefinitions.IncludePMIsAttribute, this.m_includePMIs ? 1 : 0);
    }
  }

  public TxExportGraphicsAnimationFileFormatEx PdfMode
  {
    get => this.m_pdfMode;
    set
    {
      this.m_pdfMode = value;
      this.SaveRegistryValue(CApDataFileDefinitions.PdfModeAttribute, (int) this.m_pdfMode);
    }
  }

  public CApC3DDocumentationSettings.CApC3DIncludedObjectsMode IncludedObjectsMode
  {
    get => this.m_includedObjectsMode;
    set
    {
      this.m_includedObjectsMode = value;
      this.SaveRegistryValue(CApDataFileDefinitions.IncludedObjectsMode, (int) this.m_includedObjectsMode);
    }
  }

  public int LevelOfDetails
  {
    get => this.m_levelOfDetails;
    set
    {
      this.m_levelOfDetails = value;
      this.SaveRegistryValue(CApDataFileDefinitions.LevelOfDetailsAttribute, this.m_levelOfDetails);
    }
  }

  private int? LoadRegistryValue(string valueName)
  {
    int? nullable1 = new int?();
    TxCommandPrivateDataStorage privateDataStorage = new TxCommandPrivateDataStorage((ITxCommand) new CCoC3DGeneratorCmd());
    int? nullable2;
    try
    {
      nullable2 = new int?(privateDataStorage.GetIntValue(valueName));
    }
    catch (TxCommandPrivateDataValueNotStoredException ex)
    {
      nullable2 = new int?();
    }
    return nullable2;
  }

  private void SaveRegistryValue(string valueName, int value)
  {
    new TxCommandPrivateDataStorage((ITxCommand) new CCoC3DGeneratorCmd()).SetIntValue(valueName, value);
  }

  public enum CApC3DIncludedObjectsMode
  {
    OnlyDisplayedObjectsInScene,
    OnlyObjectsIncludedInSnapshotsAndSimulation,
    AllLoadedObjects,
  }
}
